#pragma once

#include "VertexList.h"
#include "LineList.h"
#include "DAEFloat3.h"
#include "DAEMatrix.h"
#include "Ray.h"
/**
* This class creates a vertex buffer and index buffer to draw the AABB box
* The indexbuffer uses lines to draw the AABB box.
* @author Koen Samyn
*/
class AABBMesh
{
public:
	/**
	* Creates an AABBMesh from two opposing corners.
	* The world matrix is set to the identity matrix and 
	* will mirror the world matrix of the object it is representing.
	* @param device the device to use for drawing the AABBMesh
	* @param corner1 the minimum corner for the AABB mesh.
	* @param corner2 the maximum corner for the AABB mesh.
	*/
	AABBMesh(DAEFloat3 corner1, DAEFloat3 corner2);
	/**
	* Destroys the AABBMesh.
	*/
	virtual ~AABBMesh(void);
	/**
	* Performs a hittest on the AABBMesh with the specified ray.
	* @param ray the ray to check with this AABBMesh
	* @param distance the calculated distance
	* @param t0 the minimum distance for the ray hit.
	* @parma t1 the maximum distance for the ray hit.
	*/
	bool HitTest(Ray& ray, float& distance, float t0, float t1);
	
	/**
	* Returns the data of the aabbmesh.
	* @param c1x pointer to the float variable for the x value of the first corner.
	* @param c1y pointer to the float variable for the y value of the first corner.
	* @param c1z pointer to the float variable for the z value of the first corner.
	* @param c2x pointer to the float variable for the x value of the second corner.
	* @param c2y pointer to the float variable for the y value of the second corner.
	* @param c2z pointer to the float variable for the z value of the second corner.
	*/
	void GetData(float* c1x,float* c1y, float* c1z, float* c2x,float* c2y, float* c2z);
	/**
	* Returns the bottom corner of this aabb box.
	* @return the bottom corner.
	*/
	DAEFloat3& GetCorner1(){
		return m_Corner1;
	}

	/**
	* Returns the upper corner of this aabb box.
	* @return the bottom corner.
	*/
	DAEFloat3& GetCorner2(){
		return m_Corner2;
	}
private:
	DAEFloat3 m_Corner1;
	DAEFloat3 m_Corner2;
	DAEFloat3 m_Bounds[2];
	DAEMatrix m_World;

	VertexList* m_pVertexList;
	LineList* m_pLineList;
	// -------------------------
	// Disabling default copy constructor and default assignment operator.
	// If you get a linker error from one of these functions, your class is internally trying to use them. This is
	// an error in your class, these declarations are deliberately made without implementation because they should never be used.
	// -------------------------
	AABBMesh(const AABBMesh& t);
	AABBMesh& operator=(const AABBMesh& t);
};
